package com.example.utils;

import com.example.entity.constants.Constants;
import com.example.enums.UserContactTypeEnum;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;

import java.sql.Struct;

public class StringTools {

    public static String  getUserId() {
        //随机数 用户 + 电话号码11位
        return UserContactTypeEnum.USER.getPrefix() + getRandomNumber(Constants.LENGTH_11);
    }
    public static final String getRandomNumber(Integer count){
        return RandomStringUtils.random(count,false,true);
    }
    public static final String getRandomString(Integer count){
        return RandomStringUtils.random(count,true,true);
    }

    public static final String encodeMd5(String originString) {
        return StringUtils.isEmpty(originString) ? null : DigestUtils.md5Hex(originString);
    }
}
